using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace SmartLauncher
{
	class SyncItem
	{
		RepositoryItem localFile;
		RepositoryItem remoteFile;
		SyncActions action;
		string folderName;      //               Folder
		string fileName;        //                      File.ext
		int imageIndex;
		string key;
		bool isNew;

		#region "Constructors"
		public SyncItem(RepositoryItem file, bool isLocal, SyncActions syncAction)
		{
			if (isLocal == true)
			{
				localFile = file;
				string x = Path.Combine(Properties.Settings.Default.RepositoryHome, localFile.RelativePath.Substring(1));
				remoteFile = new RepositoryItem(x, false); ;
			}
			else
			{
				remoteFile = file;
				string x = Path.Combine(ApplicationStartInfo.LocalRoot, remoteFile.RelativePath.Substring(1));
				localFile = new RepositoryItem(x, true); ;
			}
			key = file.Key;
			folderName = file.FolderName;
			fileName = file.FileName;
			imageIndex = file.ImageIndex;

			action = syncAction;
		}
		#endregion

		#region "Properties"
		public bool IsNew
		{
			get { return isNew; }
			set { isNew = value; }
		}

		public RepositoryItem LocalFile
		{
			get { return localFile; }
		}

		public RepositoryItem RemoteFile
		{
			get { return remoteFile; }
		}

		public SyncActions Action
		{
			get { return action; }
			set { action = value; }
		}

		public string FolderName
		{
			get { return folderName; }
		}

		public string FileName
		{
			get { return fileName; }
		}

		public int ImageIndex
		{
			get { return imageIndex; }
		}

		public string Key
		{
			get { return key; }
		}

		public long Size
		{
			get
			{
				switch (action)
				{
					case SyncActions.None: return localFile.Size;
					case SyncActions.Copy: return remoteFile.Size;
					case SyncActions.Delete: return localFile.Size;
					default: return 0;
				}
			}
		}
		#endregion
	}
}